home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 46 / Amiga Format CD46 (1999-10-20)(Future Publishing)(GB)[!][issue 1999-12].iso / -in_the_mag- / reader_requests / scilab / man / man-part2 / cat1 / aff2ab.1 next >
Text File  |  1999-09-16  |  3KB  |  133 lines

  1.  
  2.  
  3.  
  4. aff2ab(1)                      Scilab Function                      aff2ab(1)
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11. NAME
  12.   aff2ab - linear (affine) function to A,b conversion
  13.  
  14. CALLING SEQUENCE
  15.   [A,b]=aff2ab(afunction,dimX,D [,flag])
  16.  
  17. PARAMETERS
  18.   afunction : a scilab function  Y =fct(X,D)  where X, D, Y are list of
  19.             matrices
  20.   dimX      : a p x 2 integer matrix (p is the number of matrices in X)
  21.   D         : a list of real matrices (or any other valid Scilab object).
  22.   flag      : optional parameter (flag='f' or flag='sp')
  23.   A         : a real matrix
  24.   b         : a real vector having same row dimension as A
  25.  
  26. DESCRIPTION
  27.   aff2ab  returns the matrix representation of an affine function (in the
  28.   canonical basis).
  29.   afunction is a function with imposed syntax:
  30.    Y=afunction(X,D)  where  X=list(X1,X2,...,Xp)  is a list of p real
  31.   matrices, and  Y=list(Y1,...,Yq)  is a list of q real real matrices which
  32.   depend linearly of the  Xi's. The (optional) input  D contains parameters
  33.   needed to compute Y as a function of X. (It is generally a list of
  34.   matrices).
  35.    dimX is a p x 2 matrix: dimX(i)=[nri,nci] is the actual number of rows and
  36.   columns of matrix Xi.  These dimensions determine na, the column dimension
  37.   of the resulting matrix A: na=nr1*nc1 +...+ nrp*ncp.
  38.   If the optional parameter flag='sp' the resulting A matrix is returned as a
  39.   sparse matrix.
  40.   This function is useful to solve a system of linear equations where the
  41.   unknown variables are matrices.
  42.  
  43.  
  44. EXAMPLE
  45.   // Lyapunov equation solver (one unknown variable, one constraint)
  46.   deff('Y=lyapunov(X,D)','[A,Q]=D(:);Xm=X(:); Y=list(A''*Xm+Xm*A-Q)')
  47.   A=rand(3,3);Q=rand(3,3);Q=Q+Q';D=list(A,Q);dimX=[3,3];
  48.   [Aly,bly]=aff2ab(lyapunov,dimX,D);
  49.   [Xl,kerA]=linsolve(Aly,bly); Xv=vec2list(Xl,dimX); lyapunov(Xv,D)
  50.   Xm=Xv(:); A'*Xm+Xm*A-Q
  51.  
  52.   // Lyapunov equation solver with redundant constraint X=X'
  53.   // (one variable, two constraints) D is global variable
  54.   deff('Y=ly2(X,D)','[A,Q]=D(:);Xm=X(:); Y=list(A''*Xm+Xm*A-Q,Xm''-Xm)')
  55.   A=rand(3,3);Q=rand(3,3);Q=Q+Q';D=list(A,Q);dimX=[3,3];
  56.   [Aly,bly]=aff2ab(ly2,dimX,D);
  57.   [Xl,kerA]=linsolve(Aly,bly); Xv=vec2list(Xl,dimX); ly2(Xv,D)
  58.  
  59.   // Francis equations
  60.   // Find matrices X1 and X2 such that:
  61.   // A1*X1 - X1*A2 + B*X2 -A3 = 0
  62.   // D1*X1 -D2 = 0
  63.   deff('Y=bruce(X,D)','[A1,A2,A3,B,D1,D2]=D(:),...
  64.   [X1,X2]=X(:);Y=list(A1*X1-X1*A2+B*X2-A3,D1*X1-D2)')
  65.   A1=[-4,10;-1,2];A3=[1;2];B=[0;1];A2=1;D1=[0,1];D2=1;
  66.   D=list(A1,A2,A3,B,D1,D2);
  67.   [n1,m1]=size(A1);[n2,m2]=size(A2);[n3,m3]=size(B);
  68.   dimX=[[m1,n2];[m3,m2]];
  69.   [Af,bf]=aff2ab(bruce,dimX,D);
  70.   [Xf,KerAf]=linsolve(Af,bf);Xsol=vec2list(Xf,dimX)
  71.   bruce(Xsol,D)
  72.  
  73.   // Find all X which commute with A
  74.   deff('y=f(X,D)','y=list(D(:)*X(:)-X(:)*D(:))')
  75.   A=rand(3,3);dimX=[3,3];[Af,bf]=aff2ab(f,dimX,list(A));
  76.   [Xf,KerAf]=linsolve(Af,bf);[p,q]=size(KerAf);
  77.   Xsol=vec2list(Xf+KerAf*rand(q,1),dimX);
  78.   C=Xsol(:); A*C-C*A
  79.  
  80. SEE ALSO
  81.   linsolve, vec2list
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.